Unit 3 Lesson 7 Nested Conditionals
- Nested Conditional Statements
- Format of a nested conditional in Pseudocode
- Below are some examples of nested conditionals.
- Now you try it!
IF (condition 1)
{
<first block of statements>
}
ELSE
{
IF (condition 2)
{
<second block of statements>
}
ELSE
{
<third block of statements>
}
}
age = 19
isGraduated = False
hasLicense = True
# Look if person is 18 years or older
if age >= 18:
print("You're 18 or older. Welcome to adulthood!")
if isGraduated:
print('Congratulations with your graduation!')
if hasLicense:
print('Happy driving!')
print("What is your grade on the quiz")
grade = int(input('What is your grade on the quiz'))
if grade >= 90:
print("Awesome grade. You do not need to make up the quiz.")
else:
if grade >= 70:
print("You may retake the quiz next class for up to an A.")
else:
print("We will review next class together and retake later.")
Age = 51;
if (Age == 30):
print("your old")
else:
print("you should retire")
if (Age > 50):
print("You have a beard")